Ext.define('DragonApp.view.base.Grid', {
    extend: 'Ext.grid.Panel',
    alias: ['widget.basegrid'],

    requires: [
        'DragonApp.store.JsonPBase',
        'Ext.overrides.grid.ExportGrid'
    ],

    controller: 'base',

    columns: {
        defaults: {
            align: 'center'
        },
        items: [
        { text: '日期', dataIndex: 'date', width: 100  },
        { text: '渠道', dataIndex: 'channel', width: 100  },
        { text: '服务器', dataIndex: 'sid', align: 'center' },
        { text: '新用户', dataIndex: 'register', width: 80  },
        { text: '留存率',
          columns: [
            { text: '第2日', dataIndex: 'RET2', renderer: 'attrRender', align: 'center', width: 80  },
            { text: '第3日', dataIndex: 'RET3', renderer: 'attrRender', align: 'center', width: 80  },
            { text: '第4日', dataIndex: 'RET4', renderer: 'attrRender', align: 'center', width: 80  },
            { text: '第5日', dataIndex: 'RET5', renderer: 'attrRender', align: 'center', width: 80  },
            { text: '第6日', dataIndex: 'RET6', renderer: 'attrRender', align: 'center', width: 80  },
            { text: '第7日', dataIndex: 'RET7', renderer: 'attrRender', align: 'center', width: 80  },
            { text: '第15日', dataIndex: 'RET15', renderer: 'attrRender', align: 'center', width: 80  },
            { text: '第30日', dataIndex: 'RET30', renderer: 'attrRender', align: 'center', width: 80  }
        ]},
        { text: '付费账号', dataIndex: 'skill3', width: 80  },
        { text: '收入',     dataIndex: 'skill4', width: 80  },
        { text: 'DAU',      dataIndex: 'DAU', width: 80  },
        { text: 'ARPU',     dataIndex: 'skill6', width: 80  },
        { text: 'ARPPU',    dataIndex: 'skill3', width: 80  },
        { text: 'LTV1',     dataIndex: 'skill4', width: 80  },
        { text: 'LTV3',     dataIndex: 'skill5', width: 80  },
        { text: 'LTV7',     dataIndex: 'skill6', width: 80  },
        { text: '累计用户', dataIndex: 'total', width: 80, hidden: true }
    ]},
    store: {
        type: 'jsonPBaseStore',
        storeId : 'jsonPBaseStore'
    },
    tbar: [{
        text: '导出数据',
        iconCls: 'x-fa fa-file-excel-o',
        width: 120,
        handler: function(button) {
            var grid = button.up('grid');
            var includeHiddenColumns = true;
            var title = '游戏运营基础数据';
            grid.downloadExcelXml(includeHiddenColumns, title);
        }
    }]
});